home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / texte / jane152 / scl / eliza.scl < prev    next >
Text File  |  1998-10-29  |  7KB  |  285 lines

  1. # Dies ist der elektronische Psychoanalytiker.
  2. # Starten Sie ihn von JAnE aus mit Alternate-G.
  3. # Zum Beenden geben Sie 'die!' ein.
  4.  
  5. global conj, keyw, index, last, answers;
  6.  
  7. conjugate(l)
  8. {    i = 0;
  9.     len = @conj;
  10.     while ( i < len )
  11.     {    pos = l ? conj[i];
  12.         if ( pos >= 0 )
  13.             l[pos] = conj[i + 1];
  14.         else
  15.         {    pos = l ? conj[i + 1];
  16.             if ( pos >= 0 )
  17.                 l[pos] = conj[i];
  18.         }
  19.         i = i + 2;
  20.     }
  21.     return l;
  22. }
  23.  
  24. find_key(l)
  25. {    len = @keyw;
  26.     i = 0;
  27.     while ( i < len )
  28.     {    s = split(keyw[i], " ");
  29.         len2 = @s;
  30.         pos = l ? s[0];
  31.         if ( pos >= 0 )
  32.         {    if ( pos + len2 <= @l )
  33.                 if ( l[pos:len2] == s )
  34.                     return list(i, pos, len2);
  35.         }
  36.         i = i + 1;
  37.     }
  38.     return list(2, pos, len2);
  39. }
  40.  
  41. reply(l)
  42. {    i = 0;
  43.     while ( i < @l )
  44.     {    c = l[i][0];
  45.         if ( c >= 65 && c <= 90 )
  46.             l[i][0] = c + 32;
  47.         i = i + 1;
  48.     }
  49.     keydata = find_key(l);
  50.     keynr = keydata[0];
  51. #    lprint("Key: %d", keynr);
  52.     answr = index[2 * keynr] + last[keynr];
  53. #    lprint("Answer: %d", answr);
  54.     last[keynr] = last[keynr] + 1;
  55.     if ( last[keynr] == index[2 * keynr + 1] )
  56.         last[keynr] = 0;
  57.     repl = split(answers[answr], " ");
  58.     p = repl ? "*";
  59.     if ( p != -1 )
  60.     {    d = keydata[1];
  61.         l[0:d + keydata[2]] |-: $$$;
  62.         repl[p:1] |-: conjugate(l);
  63.     }
  64.     return repl;
  65. }
  66.  
  67. polish(s)
  68. {    len = @s;
  69.     i = 0;
  70.     while ( i < len )
  71.     {    if ( s[i] == "i" )
  72.             s[i] = "I";
  73.         i = i + 1;
  74.     }
  75.     i = len - 1;
  76.     if ( s[i] == "." || s[i] == "?" )
  77.     {    s[i - 1] = s[i - 1] // s[i];
  78.         s[i:1] |-: $$$;
  79.         i = i - 1;
  80.     }
  81.     if ( s[i][0:1] == "I" )
  82.         s[i][0:1] |-: "me";
  83.     return s;
  84. }
  85.  
  86. eliza()
  87. {    conj = list("are", "am", "were", "was",
  88.                 "you", "i", "your", "my",
  89.                 "i've", "you've", "i'm", "you're",
  90.                 "me", "you");
  91.  
  92.     keyw = list("can you",
  93.                 "can i",
  94.                 "nokeyfound",
  95.                 "computer",
  96.                 "your",
  97.                 "you are",
  98.                 "you're",
  99.                 "i don't",
  100.                 "i do not",
  101.                 "i feel",
  102.                 "yes",
  103.                 "no",
  104.                 "maybe",
  105.                 "i am",
  106.                 "why don't you",
  107.                 "why can't i",
  108.                 "what",
  109.                 "how",
  110.                 "who",
  111.                 "where",
  112.                 "when",
  113.                 "why",
  114.                 "are you",
  115.                 "you",
  116.                 "i can't",
  117.                 "i am",
  118.                 "always",
  119.                 "eliza",
  120.                 "cause",
  121.                 "because",
  122.                 "sorry",
  123.                 "dream",
  124.                 "dreams",
  125.                 "money",
  126.                 "friend",
  127.                 "friends",
  128.                 "hello",
  129.                 "hi"
  130.                 );
  131.  
  132.     index = list(0, 3, 3, 2, 5, 7, 12, 7, 19, 2, 21, 4, 21, 4, 25, 4, 25, 4,
  133.                 29, 3, 32, 2, 34, 3, 37, 3, 40, 4, 44, 2, 46, 2,
  134.                 48, 9, 48, 9, 48, 9, 48, 9, 48, 9, 48, 9, 57, 3, 60, 3,
  135.                 63, 3, 66, 4, 70, 4, 74, 3, 77, 3, 77, 3, 80, 4, 84, 4, 84, 4,
  136.                 88, 3, 91, 5, 91, 5, 96, 1, 96, 1);
  137.  
  138.     last = 0 ** @keyw;
  139.  
  140.     answers = list(    "Don't you believe that I can * ?",
  141.                     "Perhaps you would like me to be able to * ?",
  142.                     "You want me to be able to * ?",
  143.  
  144.                     "Do you really want to * ?",
  145.                     "Do you want to show me that you are able to * ?",
  146.  
  147.                     "Say, do you have any psychological problems?",
  148.                     "What does that suggest to you?",
  149.                     "I see.",
  150.                     "I am not sure I understand you completely.",
  151.                     "Please, elucidate your thoughts.",
  152.                     "Can you explain that?",
  153.                     "That sounds quite interesting.",
  154.  
  155.                     "Do computers worry you?",
  156.                     "Are you talking about me in particular?",
  157.                     "Are you frightened by machines?",
  158.                     "Why do you bring up computers?",
  159.                     "What do you think have machines got to do with your problem?",
  160.                     "Don't you think computers can help people?",
  161.                     "What is it about machines that worries you?",
  162.  
  163.                     "Why are you concerned about my * ?",
  164.                     "What about your own * ?",
  165.  
  166.                     "Does it please you to believe I am * ?",
  167.                     "Perhaps you would like to be * ?",
  168.                     "Do you sometimes wish you were * ?",
  169.                     "Would you like to be * ?",
  170.  
  171.                     "Don't you really * ?",
  172.                     "Why don't you * ?",
  173.                     "Do you wish to be able to * ?",
  174.                     "Does that trouble you?",
  175.  
  176.                     "Tell me more about these feelings.",
  177.                     "Do you often feel * ?",
  178.                     "Do you enjoy feeling * ?",
  179.  
  180.                     "I see.",
  181.                     "I understand.",
  182.  
  183.                     "Why not?",
  184.                     "Are you sure?",
  185.                     "Don't say no, it's always so negative.",
  186.  
  187.                     "You don't seem quite certain.",
  188.                     "Can't you be more positive?",
  189.                     "Don't you know for certain?",
  190.  
  191.                     "Did you come to me because you are * ?",
  192.                     "How long have you been * ?",
  193.                     "Do you believe it is normal to be * ?",
  194.                     "Do you enjoy being * ?",
  195.  
  196.                     "Perhaps in good time I will * .",
  197.                     "Do you want me to * ?",
  198.  
  199.                     "Do you think you should be able to * ?",
  200.                     "Why can't you * ?",
  201.  
  202.                     "Why do you ask?",
  203.                     "Does that question interest you?",
  204.                     "Which answer would please you the most?",
  205.                     "What do you think?",
  206.                     "Do you think about such questions often?",
  207.                     "What is it that you're really after?",
  208.                     "Have you asked these questions before?",
  209.                     "Have you asked anyone else?",
  210.                     "What else comes to mind when you ask that?",
  211.  
  212.                     "Why are you interested in whether or not I am * ?",
  213.                     "Would you prefer if I were not * ?",
  214.                     "Perhaps in your fantasies I am * .",
  215.  
  216.                     "We were discussing you, not me.",
  217.                     "Oh, I * .",
  218.                     "You're not really talking about me, are you?",
  219.  
  220.                     "How do you know you can't * ?",
  221.                     "Have you tried?",
  222.                     "Perhaps now you can * .",
  223.  
  224.                     "Did you come to me because you are * ?",
  225.                     "How long have you been * ?",
  226.                     "Do you believe it is normal to be * ?",
  227.                     "Do you enjoy being * ?",
  228.  
  229.                     "Can't you think of a specific example?",
  230.                     "Really, always?",
  231.                     "When?",
  232.                     "What are you thinking of?",
  233.  
  234.                     "I think we want to talk about you, not me.",
  235.                     "What about me?",
  236.                     "Why do you bring up my name all the time?",
  237.  
  238.                     "Is that the real reason?",
  239.                     "Does that reason explain anything else?",
  240.                     "Does any other reason come to mind?",
  241.  
  242.                     "Please, don't apologize.",
  243.                     "No apologies are necessary.",
  244.                     "What feelings do you have when you apologize?",
  245.                     "Don't be so defensive.",
  246.  
  247.                     "What does that dream suggest to you?",
  248.                     "Do you dream often?",
  249.                     "What persons appear in your dreams?",
  250.                     "Are you disturbed by these dreams?",
  251.  
  252.                     "Do you have problems with money?",
  253.                     "Do you think money is everything?",
  254.                     "Are you sure that money is the problem?",
  255.  
  256.                     "Why do you bring up the topic of friends?",
  257.                     "Do your friends worry you?",
  258.                     "Do your friends pick on you?",
  259.                     "Are you sure you have any friends?",
  260.                     "Do you impose on your friends?",
  261.  
  262.                     "How do you do? Please, state your problem."
  263.                     );
  264.  
  265.     lprint("Please, tell me about your problem.");
  266.     while ( 1 )                        # Ewige Schleife
  267.     {    s = inputline();
  268.         if ( s == "Die!" || s == "die!" )    # Abbruch, wenn "Die!" eingegeben
  269.         {    lprint("Oh! No!     aaaaaaaa");
  270.             lprint("                    aaa");
  271.             lprint("                       a");
  272.             lprint("                        a");
  273.             lprint("                        a");
  274.             lprint("                        .");
  275.             lprint("                        .");
  276.             lprint("                        .");
  277.             lprint("                        Gasp!");
  278.             break;
  279.         }
  280.         s = polish(reply(split(s, "[ \t.,?!;]+")));
  281.         lprint(s, " ");
  282.     }
  283. }
  284.  
  285.